package com.zhejiangzhengyuan.municipal_common.mapper;

import com.zhejiangzhengyuan.municipal_common.entity.Department;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhejiangzhengyuan.municipal_common.entity.vo.DepartmentVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * 部门表，记录系统中涉及的相关部门数据 Mapper 接口
 * </p>
 *
 * @author linju
 * @since 2019-11-22
 */
@Repository
public interface DepartmentMapper extends BaseMapper<Department> {

    @Select("select d.name from user_info u,department d,department_user_info_mapping dum\n" +
            "            where dum.user_info_id =u.id and dum.department_id=d.id and u.id=#{uid}")
    List<String> selectDepartmentListByUserId(@Param("uid") Long id);
    @Select("select d.name from user_info u,department d,department_user_info_mapping dum,subject s,subject_user_info_mapping sum\n" +
            "where dum.user_info_id =u.id and dum.department_id=d.id and s.id=sum.subject_id and u.id=sum.user_info_id\n" +
            "and s.id=#{sid}")
    List<String> selectDepartmentListBySubjectId(@Param("sid") Long id);


    @Select("select id ,name from department")
    List<DepartmentVo> usernameVo();
}
